package dxcorp.dxadminapi.service;


import dxcorp.dxadminapi.entity.User;
import dxcorp.dxadminapi.mapper.UserMapper;
import dxcorp.dxadminapi.utils.PageResult;
import dxcorp.dxadminapi.utils.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("UserService")
//@Service
public class UserService {
    @Autowired
    UserMapper userMapper;
    public User findByUsername(User user){
        return userMapper.findByUsername(user.getUsername());
    }
    public User findUserById(String userId) {
        return userMapper.findUserById(userId);
    }

    public PageResult getUserPage(PageUtil pageUtil) {
        //当前页码中的数据列表
        List<User> users = userMapper.findUsers(pageUtil);
        //数据总条数 用于计算分页数据
        int total = userMapper.getTotalUser(pageUtil);
        PageResult pageResult = new PageResult(users, total, pageUtil.getLimit(), pageUtil.getPage());
        return pageResult;
    }




}